#include <packet.h>
#include <string.h>

Packet::Packet(unsigned int x) :_in_use(x), _packet_size(0) 
{
}

Packet::Packet(const Packet& x)
{
    _in_use = x._in_use;
    _packet_size = x._packet_size;
    memcpy(_data, x._data, _packet_size);
}

void Packet::operator=(const Packet& x)
{
    _in_use = x._in_use;
    _packet_size = x._packet_size;
    memcpy(_data, x._data, _packet_size);
}    

bool Packet::operator==(const Packet& y)
{
   if (_in_use != y._in_use || _packet_size != y._packet_size)
    return false; 
   if (memcmp(_data, y._data, _packet_size ) != 0)
       return false;
   return true;
}

unsigned short Packet::getPacketType()
{
    ethernet_header *eth = (ethernet_header *) _data;
    return ntohs(eth->type);

}
